package com.joinlabs.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.SessionAttributes;

import com.joinlabs.entity.User;
import com.joinlabs.service.IUserService;

@Controller
@RequestMapping("/dialog")
@SessionAttributes(names = {"user","userList","toUser"})
public class DialogAction {
	@Resource
	private IUserService userService;
	@RequestMapping("/show")
	public String show(ModelMap map) {
		User user = (User) map.get("user");
		List<User> userList = userService.selectGZById(user.getUserId());
		map.addAttribute("userList", userList);
		System.out.println(userList);
		return "/communication/dialog";
	}
	@RequestMapping("/info")
	@ResponseBody
	public Object info(long userId,ModelMap map) {
		System.out.println(userId);
		User toUser = userService.selectByPrimaryKey(userId);
		map.addAttribute("toUser", toUser);
		System.out.println(toUser);
		return toUser;
	}
}
